﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Ports;
using System.Threading;
namespace OtherDevice
{
    /// <summary>
    /// 上富J6P产品关曝光指令
    /// </summary>
    public class Com_ControlLightModle:COM_Base
    {
        public int Init(string comPort)
        {
            int ret = 0;
            string parameter = "38400,n,8,1";
            ret = InitCom(comPort, parameter);
            ret = InitComAddEvent(comPort, parameter);
            //ret = InitComAddEvent(ComNum, 38400,);
            return ret;

        }


        public int Set(string value)
        {
            string info = $"#ISPW={value}\r\n";
            byte[] byteArray = System.Text.Encoding.ASCII.GetBytes(info);
            int ret = SendData(byteArray, 2000);
            return ret;
        }

        public int CloseLightExposure()
        {
            int ret=Set("808501");
            Thread.Sleep(100);
            ret = Set("044180");
            Thread.Sleep(100);
            ret = Set("044200");
            Thread.Sleep(100);
            ret = Set("837000");
            Thread.Sleep(100);
            ret = Set("150100");
            Thread.Sleep(100);
            ret = Set("270300");
            Thread.Sleep(100);
            ret = Set("045000");//关闭白平衡
            Thread.Sleep(100);
            ret = Set("130A00");//关闭颜色增益
            Thread.Sleep(100);
            ret = Set("815100");//关闭背光
            Thread.Sleep(100);
            ret = Set("805D01");//调整增益：参数（0-9倍）设置尾数
            Thread.Sleep(100);

            return ret;
        }
    }
}
